package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CarDriverInfo;
import com.ruoyi.system.service.ICarDriverInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 司机列Controller
 * 
 * @author ruoyi
 * @date 2024-09-09
 */
@RestController
//@Anonymous
@RequestMapping("/system/info")
public class CarDriverInfoController extends BaseController {
	@Autowired
	private ICarDriverInfoService carDriverInfoService;

	/**
	 * 查询司机列列表
	 */
	@PreAuthorize("@ss.hasPermi('system:info:list')")
	@GetMapping("/list")
	public TableDataInfo list(CarDriverInfo carDriverInfo) {
		startPage();
		List<CarDriverInfo> list = carDriverInfoService.selectCarDriverInfoList(carDriverInfo);
		return getDataTable(list);
	}

	/**
	 * 导出司机列列表
	 */
	@PreAuthorize("@ss.hasPermi('system:info:export')")
	@Log(title = "司机列", businessType = BusinessType.EXPORT)
	@PostMapping("/export")
	public void export(HttpServletResponse response, CarDriverInfo carDriverInfo) {
		List<CarDriverInfo> list = carDriverInfoService.selectCarDriverInfoList(carDriverInfo);
		ExcelUtil<CarDriverInfo> util = new ExcelUtil<CarDriverInfo>(CarDriverInfo.class);
		util.exportExcel(response, list, "司机列数据");
	}

	/**
	 * 获取司机列详细信息
	 */
	@PreAuthorize("@ss.hasPermi('system:info:query')")
	@GetMapping(value = "/{id}")
	public AjaxResult getInfo(@PathVariable("id") Long id) {
		return success(carDriverInfoService.selectCarDriverInfoById(id));
	}

	/**
	 * 新增司机列
	 */
	@PreAuthorize("@ss.hasPermi('system:info:add')")
	@Log(title = "司机列", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody CarDriverInfo carDriverInfo) {
		return toAjax(carDriverInfoService.insertCarDriverInfo(carDriverInfo));
	}

	/**
	 * 修改司机列
	 */
	@PreAuthorize("@ss.hasPermi('system:info:edit')")
	@Log(title = "司机列", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody CarDriverInfo carDriverInfo) {
		return toAjax(carDriverInfoService.updateCarDriverInfo(carDriverInfo));
	}

	/**
	 * 删除司机列
	 */
	@PreAuthorize("@ss.hasPermi('system:info:remove')")
	@Log(title = "司机列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
	public AjaxResult remove(@PathVariable Long[] ids) {
		return toAjax(carDriverInfoService.deleteCarDriverInfoByIds(ids));
	}

	/**
	 * 查询司机列列表
	 */
	@PostMapping("/listOpen")
	public TableDataInfo listOpen(@RequestBody CarDriverInfo carDriverInfo) {
		startPage();
		List<CarDriverInfo> list = carDriverInfoService.selectCarDriverInfoList(carDriverInfo);
		return getDataTable(list);
	}
	
	/**
	 * 获取司机列详细信息
	 */
	@GetMapping(value = "getInfoOpen/{id}")
	public AjaxResult getInfoOpen(@PathVariable("id") Long id) {
		return success(carDriverInfoService.selectCarDriverInfoById(id));
	}
	
	/**
	 * 新增司机列
	 */
	@PostMapping("/addOpen")
	public AjaxResult addOpen(@RequestBody CarDriverInfo carDriverInfo) {
		return toAjax(carDriverInfoService.insertCarDriverInfo(carDriverInfo));
	}


}
